package com.hjqjl.mvvmdemo.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.hjqjl.mvvmdemo.model.User;
import com.hjqjl.mvvmdemo.repository.UserRepository;

/**
 * 2022/9/13 17:09 wh
 */
public class UserViewModel extends AndroidViewModel {
    private LiveData<User> user;
    private UserRepository userRepository;
    private String userName = "MichaelYe";

    public UserViewModel(@NonNull Application application) {
        super(application);
        userRepository = new UserRepository();
        user = userRepository.getUser(userName);
    }

    public LiveData<User> getUser() {
        return user;
    }

    public void refresh() {
        userRepository.refresh(userName);
    }
}

